home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d20
/
doorskl3.arc
/
XBBSMSG.ARC
/
WRITLINE.C
< prev
next >
Wrap
C/C++ Source or Header
|
1992-01-15
|
2KB
|
72 lines
#include <stdlib.h>
#include <string.h>
/* Return a line from a message */
char * _fastcall write_line (char *line, char **text,
unsigned int linelen, int ctla) {
register unsigned int x = 0;
char *p;
char *pp;
*line = 0;
if(!*text) return "";
p = *text;
while(*p == '\n' || *p == '\x8d') p++; /* skip junk */
while(*p == '\01' && !ctla) { /* skip ctrl lines */
while(*p != '\r' && *p) p++;
while(*p == '\r' || *p == '\n' || *p == '\x8d') p++;
}
*text = p; /* set to start of what will be displayed */
if(!**text) return *text;
pp = line;
while(++x < (linelen + 1) && *p && *p != '\r') {
if(*p == '\n' || *p == '\x8d') {
p++;
x--;
continue;
}
*pp = *p;
p++;
pp++;
*pp = 0;
}
if(*p == '\r') {
*pp = 0;
p++;
}
else if(*p == ' ') {
*pp = 0;
while(*p == ' ') p++;
}
else if(x == (linelen + 1)) {
if(strchr(line,' ')) {
while(p > *text && *pp != ' ') {
*pp = 0;
pp--;
p--;
}
if(p == *text) {
strncpy(line,*text,linelen + 1);
line[linelen + 1] = 0;
p = text[linelen + 1];
}
else p++;
}
}
while(*pp == ' ' && pp > line) { /* Rstrip returned string */
*pp = 0;
--pp;
}
pp = *text;
*text = p;
return pp;
}